{aide_template 'common/header'}
<link href="{$aideUrl}web/resource/css/util.min.css" rel="stylesheet">
<script type="text/javascript" src="{$aideUrl}web/resource/js/util.min.js?v=20170912"></script>
<style>
    .label-default{background-color:#d1dade;color:#5e5e5e;}
    .input-group-addon .radio-inline, .input-group-addon .checkbox-inline{padding-top:0; line-height:0.95;}
    .dropdown-menu{ min-width:145px; }
    .multi-img-details .multi-item{height:auto;}
    #member.multi-img-details .multi-item{text-align:center; max-width:100px;}
    #member.multi-img-details .multi-item img{ max-width:90px; max-height:90px;}
    #member.multi-img-details .multi-item .title{ overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
    #myTab2.nav-tabs{border-color: #1ab394;}
    #myTab2.nav-tabs>li>a{border-radius:0!important;padding: 7px 15px;}
    #myTab2.nav-tabs>li>a:hover{ color:#333}
    #myTab2.nav-tabs>li.active>a, #myTab2.nav-tabs>li.active>a:hover, #myTab2.nav-tabs>li.active>a:focus{color: #FFF;border-radius:0;background-color: #1ab394;border-color: #1ab394;}
    #options.markethide .optmarket, .markethide.market{display:none}
</style>
<link href="{$_W['siteroot']}web/resource/components/select2/select2.min.css" rel="stylesheet">
{if $op == 'post'}
<ol class="breadcrumb we7-breadcrumb" style="display:none">
    <a href="./index.php?c=site&amp;a=article&amp;"><i class="wi wi-back-circle"></i> </a>
    <li><a href="./index.php?c=site&amp;a=article&amp;">文章管理</a></li>
    <li><a href="./index.php?c=site&amp;a=article&amp;do=post&amp;">文章编辑</a></li>
</ol>
<ul class="nav nav-tabs" id="myTab">
    <li class="active"><a href="#tab_basic">活动描述</a></li>
</ul>

<div class="main">
    <form action="" method="post" onsubmit="return check(this)" class="form-horizontal form" enctype="multipart/form-data">
        <input type="hidden" name="knowid" value="{$knowid}"/>
        <div class="tab-content" style="height: 500px">
            <div class="tab-pane in active" id="tab_basic">
                <div class="panel panel-default">
                    <div class="panel-heading">基本设置</div>
                    <div class="panel-body">
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">文章标题</label>
                            <div class="col-sm-6 col-xs-12">
                                <input type="text" name="know[title]" class="form-control" value="{$know['title']}" placeholder="活动名称"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">活动分类</label>
                            <div class="col-md-6">
                                <select class="form-control" name="know[categoryid]">
                                    {loop $category $k=>$v}
                                    <option value="{$v['id']}" {if $know['categoryid']==$v['id']}selected="selected"{/if}>{$v['name']}</option>
                                    {/loop}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">缩略图片</label>
                            <div class="col-sm-9 col-xs-12">
                                <input type="hidden" name="thumb_old" value="{$know['image']}">
                                {php echo tpl_form_field_image('know[image]', $know['image']);}
                                <span class="help-block">图片建议大小：640×380像素</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">简要概述</label>
                            <div class="col-sm-9 col-xs-12">
                                <textarea class="form-control" name="know[intro]" rows="3" placeholder="活动简要概述，建议30个字符左右">{$know['intro']}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">文章内容</label>
                            <div class="col-sm-9 col-xs-12">
                                {php echo tpl_ueditor('know[content]', $know['content'], array('height'=>300));}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group" style="text-align:center;">
            <div class="col-xs-12">
                <input name="submit" type="submit" value="　　保存　　" class="btn btn-primary"/>
                <input type="hidden" name="token" value="{$_W['token']}"/>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        window.optionchanged = false;
        //
        $(".js-atype input[name='know[atype]']").click(function(){
            var obj = $(this);
            if (obj.val()!='2'){
                $("#options").addClass('markethide');
                $(".market").addClass('markethide');
            }else{
                $("#options").removeClass('markethide');
                $(".market").removeClass('markethide');
            }
        });
        //
        $(".js-kefu input[name='know[kefu][type]']").click(function(){
            var obj = $(this);
            if (obj.val()!='2'){
                $(".kefu-url").hide();
                $(".kefu-qrcode").show();
            }else{
                $(".kefu-url").show();
                $(".kefu-qrcode").hide();
            }
        });
    });
    function check(form) {
        var id="{$knowid}",mid="{MERCHANTID}",proreview="{php echo $_W['_config']['proreview']==1 || ($_W['_config']['proreview']==2 && $know['aprice']==0)?1:0;}";
        if (id!='' && proreview=='0' && mid!=''){
            if(!confirm('修改后将进入审核状态，是否确认？')) {
                return false;
            }
        }else{
            return true;
        }
    }
</script>
{elseif $op == 'display'}
<div class="panel panel-default">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">
        <form action="./index.php" method="get" class="form-horizontal" role="form" id="form">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="aide_activity" />
            <input type="hidden" name="do" value="know" />
            <input type="hidden" name="ac" value="know" />
            <input type="hidden" name="op" value="display" />
            <div class="form-group">
                <label class="col-md-2 control-label">所属分类</label>
                <div class="col-sm-3 col-xs-3">
                    <select name="type" class="form-control">
                        <option value="0"></option>
                        {loop $temp $value}
                        <option value="{$value['id']}" {if $_GPC['type'] == $value['id']}selected{/if}>{$value['name']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label">标题</label>
                <div class="col-md-8">
                    <input type="text" class="form-control" name="keyword" id="keyword" value="{$_GPC['keyword']}" />
                </div>
                <div class="pull-right col-md-2">
                    <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                </div>
            </div>
        </form>
    </div>
</div>
<form class="form-horizontal" action="" method="post">
    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="panel-title">活动列表<span class="color-default pull-right">【点击活动标题复制连接】</span></div>
        </div>
        <div class="table-responsive">
            <table class="table table-hover table-bordered">
                <thead class="navbar-inner">
                <tr>
                    <th class="text-center" style="width:40px;">
                        <input type="checkbox" name="checkall" value="" id="checkall" onClick="var ck = this.checked; $(':checkbox').each(function(){this.checked = ck});">
                    </th>
                    <th class="text-center" style="width:40px;">ID</th>
                    <th class="text-left">知道标题</th>
                    <th class="text-left">所属分类</th>
                    <th class="text-center" style="width:330px;">操作</th>
                </tr>
                </thead>
                <tbody style="text-align: center;">
                    {loop $know $item}
                    <tr>
                        <td class="text-center"><input type="checkbox" name="check" value="{$item['id']}" class="items"></td>
                        <td>{$item['id']}</td>
                        <td class="text-left">{$item['title']}</td>
                        <td class="text-left">{$category[$item['categoryid']]['name']}</td>
                        <td class="text-center">
                            <div class="btn-group">
                                <a href="{php echo web_url('know/know/post', array('knowid' => $item['id']))}" class="btn btn-success btn-sm">编辑</a>
                                <a href="javascript:void(0);" class="js-delete btn btn-danger btn-sm" data-id="{$item['id']}">删除</a>
                            </div>
                        </td>
                    </tr>
                    {/loop}
                </tbody>
            </table>
        </div>
    </div>
    <div class="pull-right">{$pager}</div>
</form>
<script>
    //删除效果b，单条操作
    $('.js-delete').click(function(e) {
        e.stopPropagation();
        var $this = $(this);
        var knowid = $this.data('id');
        util.nailConfirm(this, function(state) {
            if (!state) return;
            $.post("{php echo web_url('know/know/delete')}", {knowid : knowid}, function(data) {
                if(!data.errno){
                    $this.parents('tr').remove();
                }
                util.tips(data.message);
            }, 'json');
        }, {html:"确定删除？",placement: $this.data('placement')});
    });
</script>
{/if}
{aide_template 'common/footer'}
